package com.yonyou.pmclouds.constructionlog.process;

import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.constructionlog.entity.ConstructionLogVO;
import com.yonyou.pmclouds.inspectitem.entity.InspectItemVO;
import com.yonyou.pmclouds.inspectitem.rmiitf.InspectItemService;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ConstructionLogUpdateInspectItemProcess implements SingleProcessor<ConstructionLogVO> {
    @Autowired
    private InspectItemService itemService;

    @Override
    public void process(ConstructionLogVO vo, ConstructionLogVO orig) throws BusinessException {
        InspectItemVO[] itemVOs = vo.getInspectitems();
        if (ArrayUtils.isEmpty(itemVOs)) {
            return;
        }
        String pk_constructionlog = vo.getPk_constructionlog();
        for (InspectItemVO inspectItemVO : itemVOs) {
            inspectItemVO.setPk_bill(pk_constructionlog);
            inspectItemVO.setPk_project(vo.getPk_project());
        }
        // 修改检查项
        itemService.update(itemVOs, vo);
    }

}